package com.jingbaoduo.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jingbaoduo.common.R;
import com.jingbaoduo.domain.Category;
import com.jingbaoduo.service.CategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/category")
public class CategoryController {
    @Autowired
    private CategoryService categoryService;

    @GetMapping
    public R<List<Category>> list(){


        List<Category> list = categoryService.list();
        if (list == null){
           return R.error("查询失败");
        }
        return R.success(list);
    }
}
